winsafe\taskschd\com_interfaces/
itriggercollection.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::ole::privs::*;
6use crate::prelude::*;
7use crate::taskschd::vts::*;
8
9com_interface! { ITriggerCollection: "85df5081-1b24-4f32-878a-d9d14df4cb77";
10	/// [`ITriggerCollection`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nn-taskschd-itriggercollection)
11	/// COM interface.
12	///
13	/// Automatically calls
14	/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
15	/// when the object goes out of scope.
16}
17
18impl oleaut_IDispatch for ITriggerCollection {}
19impl taskschd_ITriggerCollection for ITriggerCollection {}
20
21/// This trait is enabled with the `taskschd` feature, and provides methods for
22/// [`ITriggerCollection`](crate::ITriggerCollection).
23///
24/// Prefer importing this trait through the prelude:
25///
26/// ```no_run
27/// use winsafe::prelude::*;
28/// ```
29pub trait taskschd_ITriggerCollection: oleaut_IDispatch {
30	fn_com_noparm! { Clear: ITriggerCollectionVT;
31		/// [`ITriggerCollection::Clear`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itriggercollection-clear)
32		/// method.
33	}
34
35	/// [`ITriggerCollection::Create`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itriggercollection-create)
36	/// method.
37	#[must_use]
38	fn Create(&self, trigger_type: co::TASK_TRIGGER_TYPE2) -> HrResult<ITrigger> {
39		let mut queried = unsafe { ITrigger::null() };
40		ok_to_hrresult(unsafe {
41			(vt::<ITriggerCollectionVT>(self).Create)(
42				self.ptr(),
43				trigger_type.raw(),
44				queried.as_mut(),
45			)
46		})
47		.map(|_| queried)
48	}
49
50	/// [`ITriggerCollection::get_Count`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itriggercollection-get_count)
51	/// method.
52	#[must_use]
53	fn get_Count(&self) -> HrResult<i32> {
54		let mut count = 0i32;
55		ok_to_hrresult(unsafe {
56			(vt::<ITriggerCollectionVT>(self).get_Count)(self.ptr(), &mut count)
57		})
58		.map(|_| count)
59	}
60
61	/// [`ITriggerCollection::get_Item`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itriggercollection-get_item)
62	/// method.
63	#[must_use]
64	fn get_Item(&self, index: i32) -> HrResult<ITrigger> {
65		let mut queried = unsafe { ITrigger::null() };
66		ok_to_hrresult(unsafe {
67			(vt::<ITriggerCollectionVT>(self).get_Item)(self.ptr(), index, queried.as_mut())
68		})
69		.map(|_| queried)
70	}
71
72	/// [`ITriggerCollection::Remove`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itriggercollection-remove)
73	/// method.
74	fn Remove(&self, index: i32) -> HrResult<()> {
75		ok_to_hrresult(unsafe {
76			(vt::<ITriggerCollectionVT>(self).Remove)(self.ptr(), Variant::I4(index).to_raw()?)
77		})
78	}
79}